﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Security.Cryptography;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using QLCHBANGIAY.COMMON;
using QLCHBANGIAY.DATA;
using QLCHBANGIAY.BUSINESS;

namespace QuanLyBanGiay.Trangweb
{
    public partial class Dangnhap : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            txtID.Focus();
        }

        protected void submit_Click(object sender, EventArgs e)
        {
            string user = txtID.Text ;
           // System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
          //  byte[] hashedDataBytes = md5.ComputeHash(System.Text.UTF8Encoding.UTF8.GetBytes(txtPassword.Text.Trim()));
            //string pas = Convert.ToBase64String(hashedDataBytes);
            string pas = txtPassword.Text;
            string chuoi = null;
            List<Custommer> list = new List<Custommer>();
            list = CustommerServices.Custommer_GetByTop("1", "vusername='" + user + "' and vpassword='" + pas + "'", "iusid");
            if (list.Count > 0)
            {
                //FromsAuthentication.SetAuthCookie(user, false);
                FormsAuthentication.SetAuthCookie(user, false);
                Session["Dangnhap"] = list[0].iusid.Trim();
                Session["Dangnhap1"] = list[0].vcusname.Trim();
                chuoi += "";
               // Response.Redirect(Request.Url.LocalPath.ToString());
                Response.Redirect("/index.aspx");

            }
            else
            {
              //  Comon.WebMsgBox.Show("Sai thông tin đăng nhập");
                Response.Write("<Script> alert('nhập sai mật khẩu hoặc password');</Script>");
            }
        }
       
    }
}